<?php

namespace app\Func;
use Redis;

/**
 * Class Common
 * @package App\Func
 */
class RedisFunc
{

    protected $redis;

    public function __construct()
    {
        $this->redis = new Redis();
        $this->redis->connect('127.0.0.1', '6379');
    }

    public function _set($key, $val, $expire)
    {
        $this->redis->set($key, serialize($val));
        $this->redis->expire($key, $expire);

    }

    public function _get($key)
    {
        return unserialize($this->redis->get($key));
    }

    public function _exists($key)
    {
        return $this->redis->exists($key);
    }

}



